package com.xiaowen.producer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 生产者
 * @author xiaowen
 *
 */
@RestController
@RequestMapping("/producer")
public class ProducerKafkaController {

	@Autowired
	private KafkaTemplate<String, String> kafkaTemplate;
	
	@RequestMapping("/send")
	public String send(String msg) {
		//使用kafka模板发送信息
		kafkaTemplate.send("test",msg);
		return "success";
	}
}
